package com.habdqn.easybuy.web.front.page;

import com.habdqn.easybuy.entity.ProductCategory;
import com.habdqn.easybuy.service.ProductCategoryService;
import com.habdqn.easybuy.service.impl.ProductCategoryServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author Xing.Jiejian
 * @date 2020/12/1
 */
@WebServlet(name = "FrontHeaderServlet",urlPatterns = "/front/header")
public class FrontHeaderServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取所有分类
        ProductCategoryService productCategoryService = new ProductCategoryServiceImpl();
        List<ProductCategory> categories = productCategoryService.queryAll();
        request.setAttribute("categories",categories);
        request.getRequestDispatcher("/WEB-INF/front/page/front-header.jsp").forward(request,response);
    }
}
